# Include this directory
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})

# Numerics package.
SET(DEPENDENT_LIBS "")
SET(DEPENDENT_INCLUDES "")
SET(DEPENDENT_DEFINITIONS "")

IF (UMFPACK_FOUND)
    LIST(APPEND DEPENDENT_DEFINITIONS -DWITH_UMFPACK)
    LIST(APPEND DEPENDENT_INCLUDES ${UMFPACK_INCLUDES})
    LIST(APPEND DEPENDENT_LIBS ${UMFPACK_LIBRARIES})
ENDIF (UMFPACK_FOUND)

IF (CHOLMOD_FOUND)
    LIST(APPEND DEPENDENT_DEFINITIONS -DWITH_CHOLMOD)
    LIST(APPEND DEPENDENT_INCLUDES ${CHOLMOD_INCLUDES})
    LIST(APPEND DEPENDENT_LIBS ${CHOLMOD_LIBRARIES})
ENDIF (CHOLMOD_FOUND)

IF (METIS_FOUND)
    LIST(APPEND DEPENDENT_DEFINITIONS -DWITH_METIS)
    LIST(APPEND DEPENDENT_INCLUDES ${METIS_INCLUDES})
    LIST(APPEND DEPENDENT_LIBS ${METIS_LIBRARIES})
ENDIF (METIS_FOUND)

IF (MKL_FOUND)
    LIST(APPEND DEPENDENT_DEFINITIONS -DWITH_MKL)
ENDIF (MKL_FOUND)

# Enumerate source files
FILE(GLOB_RECURSE SRC_FILES *.cpp)
FILE(GLOB_RECURSE INC_FILES *.h *.hh)

ADD_LIBRARY(lib_SparseSolver SHARED ${SRC_FILES} ${INC_FILES})
SET_TARGET_PROPERTIES(lib_SparseSolver PROPERTIES OUTPUT_NAME "SparseSolver")
TARGET_LINK_LIBRARIES(lib_SparseSolver Mesh ${DEPENDENT_LIBS})
TARGET_INCLUDE_DIRECTORIES(lib_SparseSolver SYSTEM PRIVATE ${DEPENDENT_INCLUDES})
TARGET_COMPILE_DEFINITIONS(lib_SparseSolver PRIVATE ${DEPENDENT_DEFINITIONS})

ADD_CUSTOM_TARGET(SparseSolver DEPENDS lib_SparseSolver)
